package reci.journal.junit;

import org.junit.Test;

import reci.journal.Journal;

/*
 * Copyright (C) 2014 ReciGames
 * See notice in reci.journal.Main.java.
 */

public class DurationTest
{
	/**
	 * Prints average time to open and close a journal.
	 * 
	 * @param journalPath
	 * @param password
	 */
	@Test
	public void timeOpenCloseJournal()
	{
		String journalPath="asdf.rj";
		char[] password="".toCharArray();
		int numIterations=100;
		long start=System.currentTimeMillis();
		
		try
		{
			for(int i=0; i<numIterations; i++)
			{
				if(i%25==0)
				{
					System.out.println("i="+i);
				}
				
				Journal.login(journalPath,password.clone());
				Journal.logout();
			}
			
			long stop=System.currentTimeMillis();
			System.out.println((stop-start)*1./numIterations+"ms / iteration");
			System.out.println("Time elapsed: "+(stop-start)+"ms");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}
